<?php
/**
 * Created by PhpStorm.
 * User: xp
 * Date: 2021/4/6
 * Time: 16:19
 */

namespace plugin\admin\app\model\admin;


use App\Common\Lib\Common;
use App\Exceptions\UserException;
use App\Model\BaseModel;
use Illuminate\Support\Facades\Cookie;
use plugin\admin\app\model\Base;

class LoginRecord extends Base
{
    protected $table = 'wa_login_record';

    protected $primaryKey = 'loginid';

    public $timestamps = false;

    protected static $instance;

    public static function getInstance()
    {
        //        if(is_object(self::$instance)){
//            return self::$instance;
//        }

        return new self();
    }

    public function insertData($adminId, $loginname, $token)
    {
        $insert = [
            'adminid'=> $adminId,
            'loginname'=> $loginname,
            'createtime'=> date('Y-m-d H:i:s'),
            'login_ip'=> request()->getRealIp(),
            'token'=> $token,
        ];

        return $this->insertGetId($insert);
    }
}
